package com.jason.queue;

import lombok.SneakyThrows;

import java.util.concurrent.BlockingDeque;
import java.util.concurrent.BlockingQueue;

public class Producer implements Runnable{

    private BlockingQueue<Integer> queue;

    public Producer(BlockingQueue<Integer> queue) {
        this.queue = queue;
    }

    @SneakyThrows
    @Override
    public void run() {
        //模拟生产者生产数据，隔20ms放一个数据

        for (int i = 0; i < Integer.MAX_VALUE; i++) {
            Thread.sleep(50);
            queue.put(i);
            System.out.println(Thread.currentThread().getName()+" 生产 " +queue.size());
        }


    }
}
